package com.bicon.life.core.base.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPoolConfig;
import com.bicon.life.core.base.config.GlobalRedisConfig;

import javax.annotation.PostConstruct;

/**
 * Created by L on 2017/3/1.
 */
@Component
public class GlobalPoolConfig extends JedisPoolConfig {

    @Autowired
    private GlobalRedisConfig globalRedisConfig;


    @PostConstruct
    public void init(){
        setMaxTotal(globalRedisConfig.getMaxActive());
        setMaxIdle(globalRedisConfig.getMaxIdle());
        setMaxWaitMillis(globalRedisConfig.getMaxWait());
        setMinEvictableIdleTimeMillis(globalRedisConfig.getMinTimeMillis());
        setMinIdle(globalRedisConfig.getMinIdle());
        setNumTestsPerEvictionRun(globalRedisConfig.getNumTestsPerEvictionRun());
        setTimeBetweenEvictionRunsMillis(globalRedisConfig.getTimeBetweenEvictionRunsMillis());
    }
}
